<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="VersionId" width="95" prop="date">
          <template slot-scope="list">
              <span>{{list.row.versionId}}</span>
          </template>
      </el-table-column>
      <el-table-column label="文件路径"  prop="name" >
        <template slot-scope="list">
          <span>{{list.row.filePath}}</span>
        </template>
      </el-table-column>
      <el-table-column label="当前版本标识" width="150" align="center" prop="address">
        <template slot-scope="list">
          <span>{{list.row.currentVersionTag}}</span>
        </template>
      </el-table-column>
      <el-table-column label="新版本" width="110" align="center">
        <template slot-scope="list">
          <span>{{list.row.newVersion}}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="当前版本" width="110" align="center">
        <template slot-scope="list">
          <span>{{list.row.thisVersion}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="created_at" label="补丁轮" width="200">
        <template slot-scope="list">
          <span>{{list.row.polls}}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getList } from '@/api/table'
import axios from 'axios';
export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'gray',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }],
      list: [],
      listLoading: true
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      axios.get('/web/getversion/patch').then( (response) => {
        console.log(response.data.data);
        this.list.push(response.data.data);
        console.log(self.list)
        this.listLoading = false;
      })
    }
  }
}
</script>
